#coding:utf8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from flask_babel import gettext as _

def res(args1,args2,lists=[]):
    menus = [
        {
            'dishes':{
                'name': _('商品管理'),'target': '/dishes','show': False,'active': '',
                'sub_menus': [
                    [43,'/dishes', _("商品资料"), False, 'dishes',''],
                    [59, '/dishes/cate', _("菜品分类"), False, 'dishes_cate', ''],
                    [53,'/dishes/menus', _("套餐设置"), False, 'dishes_menus',''],
                    [59,'/dishes/remark', _("商品备注"), False, 'dishes_remark',''],
                ]
            }
        },
        # {
        #     'cloud_dishes': {
        #         'name': _('线上商品管理'), 'target': '/cloud_dishes', 'show': False, 'active': '',
        #         'sub_menus': [
        #             [43, '/cloud/dishes', _("线上商品资料"), False, 'cloud_dishes', ''],
        #             [59, '/cloud/dishes/cate', _("线上菜品分类"), False, 'dishes_cate', ''],
        #             [53, '/cloud/dishes/menus', _("线上套餐设置"), False, 'dishes_menus', ''],
        #             [59, '/cloud/dishes/remark', _("线上商品备注"), False, 'dishes_remark', ''],
        #         ]
        #     }
        # },
        {
            'sales': {
                'name':_( '销售管理'), 'target': '/sales', 'show': False, 'active': '',
                'sub_menus': [
                    [36, '/sales', _("营销概况"), False, 'sales',''],
                    [37, '/sales/order', _("交易记录"), False, 'sales_order',''],
                    [38, '/sales/shift', _("交班记录"), False, 'sales_shift',''],
                    [39, '/sales/trend/analysis', _("局势分析"), False, 'sales_trend_analysis',''],
                    [40, '/sales/dishe/analysis', _("商品分析"), False,'sales_dishe_analysis', ''],
                    [41, '/sales/cate/analysis', _("品类分析"),  False, 'sales_cate_analysis',''],
                    [39, '/sales/order/analysis', _("订单统计"), False, 'sales_order_analysis', ''],
                    [42, '/sales/other/analysis', _("其它统计"), False,'sales_other_analysis', ''],
                ]
            }
        },
        {
            'coupons': {
                'name': _('营销活动'), 'target': '/coupons', 'show': False, 'active': '',
                'sub_menus': [
                     [36, '/coupons', _("优惠卷管理"), False, 'coupons',''],
                     [36, '/coupons/tj',_("优惠卷统计"), False, 'coupons_tj',''],
                     [36, '/coupons/used', _("使用列表"), False, 'coupons_used',''],
                ]
           }
        },
        {
            'store': {
                'name': _('分店管理'), 'target': '/store', 'show': False, 'active': '',
                'sub_menus': [
                    [100, '/store', _("分店列表"), False, 'store', '']
                ]
            }
        },
        {
            'member': {
                'name': _('会员管理'), 'target': '/member', 'show': False, 'active': '',
                'sub_menus': [
                    [75, '/member', _("会员资料"), False, 'member',''],
                    [76, '/member/cate', _("会员类型"), False,'member_cate', ''],
                ]
            }
        },
        {
            'staff': {
                'name': _('员工管理'), 'target': '/staff', 'show': True, 'active': '',
                'sub_menus': [
                    [83, '/staff', _("员工资料"), True, 'staff','']
                ]
            }
        },
        {
            'system': {
                'name': _('系统设置'), 'target': '/system/table', 'show': False, 'active': '',
                'sub_menus': [
                    [83, '/system/table', _("台位管理"), False, 'system_table',''],
                    [100, '/system/print', _("打印设置"), False, 'system_print',''],
                ]
            }
        },

    ]

    #print lists
    sub_menus=['','']
    for i in menus:
        for n in i:
            if n==args1:
                i[n]['active'] = 'active'
                sub_menus[0]=i[n]['name']
            for m in i[n]['sub_menus']:
                #if lists[m[0]-1]:
                if m[4] in lists:
                    #print m[4],m
                    i[n]['show']=True
                    m[-3] = True
                    if args2==m[-2]:
                        m[-1]='active'
                        sub_menus[1]=m[2]

    #print menus
    return menus,sub_menus

if __name__ == "__main__":
    menus,sub_menus=res('','dishes_cate',['dishes','dishes_cate','dishes_menus'])
    for i in menus:
        for n in i:
            if i[n]['show']:
                for m in i[n]['sub_menus']:
                    #m[3]=Falsem
                    print m
                    print '\t', m[1]
    print sub_menus
    print menus
